## code optimize
INIT = task_init_merge.cc
INIT_LIB = libtask_init.so
## add case and unroll
INIT_ye = task_init_ye.cc
INIT_ye_LIB = libtask_init_ye.so

MUL = task_mul_t.cc 
MUL_LIB = libtask_mul.so
## the second loop will not be better
#MUL = task_mul_t2.cc  

# add #pragma (guided) in task_ye_avx256 
#  change the #pragma a little ,which is a little better.  
OMP= task_omp_ye_avx256.cc
OMP_LIB = libtask_omp.so

# add "avx_256" into task_init_ye.cc
AVX = task_ye_avx256.cc
AVX_LIB = libtask_ye_avx256.so

PRE= task_prefetch.cc
PRE_LIB = libtask_pre.so

LOOP = 100
NUM = 4096

omp:$(OMP)
	g++ ${OMP} -O2 -fopenmp -shared -fPIC  -o ${OMP_LIB}
omp_run:$(OMP_LIB)
	./testApp -load ./$(OMP_LIB) -loop $(LOOP) -matrixnum $(NUM)

pre:$(PRE)
	g++ ${PRE} -O2 -shared -fPIC  -o ${PRE_LIB}
pre_run:$(PRE_LIB)
	./testApp -load ./$(PRE_LIB) -loop $(LOOP) -matrixnum $(NUM)

init:$(INIT)
	g++ ${INIT} -O2 -shared -fPIC  -o ${INIT_LIB}
init_run:$(INIT_LIB)
	./testApp -load ./$(INIT_LIB) -loop $(LOOP) -matrixnum $(NUM)

initye:$(INIT_ye)
	g++ ${INIT_ye} -O2 -shared -fPIC  -o ${INIT_ye_LIB}
initye_run:$(INIT_ye_LIB)
	./testApp -load ./$(INIT_ye_LIB) -loop $(LOOP) -matrixnum $(NUM)



mul:$(MUL)
	g++ ${MUL} -O2 -fopenmp -shared -fPIC  -o ${MUL_LIB}
mul_run:$(MUL_LIB)
	./testApp -load ./$(MUL_LIB) -loop $(LOOP) -matrixnum $(NUM)


avx:$(AVX)
	g++ ${AVX} -O2 -mfma -shared -fPIC  -o ${AVX_LIB}
avx_run:$(AVX_LIB)
	./testApp -load ./$(AVX_LIB) -loop $(LOOP) -matrixnum $(NUM) -tol 1e-13

clean:
	rm -f *.so *.o

